chrome.webRequest.onBeforeRequest.addListener(
	function(details) {
		console.log('details=======', details)
		message_tab(details['type'])
		// return true
		return {
			redirectUrl: chrome.extension.getURL("tihuan.js")
		}; //你要替换的js脚本
	},

	{
		urls: [
			"https://shop.vipstatic.com/js/public/core3.1.0-hash-7b2cbd2b.js?20210701"
			// "<all_urls>"
		], //你要拦截的url地址

		types: [
			"main_frame",
			"sub_frame",
			"stylesheet",
			"script",
			"image",
			"object",
			"xmlhttprequest",
			"other"
		] //拦截类型为script，

	},
	["blocking"] //类型blocking为拦截,

);


//向标签页发送信息
function message_tab(Ymessage) {
	chrome.tabs.query({
		active: true,
		currentWindow: true
	}, function(tabs) {
		chrome.tabs.sendMessage(tabs[0].id, {
			'Ymessage': Ymessage
		}, function(response) {
			//向 content_script 发送消息
		});
	})
}
